﻿Filter BuildChart {
	param(
	[string]$ChartName,
	[string]$xLabel,
	[string]$yLabel,
	[string]$key,
	$value,
	$SeriesType	
	)

	Begin 
	{ 
	    $hash = @{}	    
	    $SeriesName = ""
	    $datapointsValue = ""
	    $DatapointsName = ""
	    $data = $ChartName + "µ" + $xLabel + "µ" + $yLabel + "µ" + "£"
	    foreach ($serieType in $seriesType)
	    {
	        $data += $serieType + "µ"
	    }
	    $data += "£"
	    
	    foreach ($v in @($value))
	    {	     
	        $SeriesName += $v.ToString() + "µ"
	    }
	}
	Process
	{
	    $thisKey = $_.$Key
	    $DatapointsName += $thisKey + "µ"
	    
	    foreach ($v in @($value))
	    {
	        $datapointsValue += $_.$v.ToString() + "¤"	     
	    }
	    
	    $datapointsValue += "µ"
	}
	End
	{
        $datapointsvalue += "£"
        $seriesName += "£"
        $datapointsname += "£"
        $data += $seriesName + $DatapointsName + $datapointsvalue + "§"
        return $data
	}
}

#$Dash = ""
#$Dash += gwmi Win32_logicalDisk –Filter “DriveType = 3”|buildchart "Hard Disk" "Drive" "Size" deviceId @('Size','freespace') @("StackedColumn","StackedColumn")
#$Dash += gwmi Win32_OperatingSystem | buildchart "Memory" "Total" "Free" "memory" @('TotalVisibleMemorySize','FreePhysicalMemory') "Pie"
#$Dash += get-process |sort Handles|select -first 10| buildchart "Processes" "" "Handles" ProcessName @('Handles') @("Bar")
#$Dash



#get-service|format-grid -p Name,DisplayName,Status,CanshutDown